package com.myBase.core.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

public class EBeiUtil {
    /**
     * 生成OrderId
     */
    public static String[] chars = new String[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
            "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8",
            "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
            "U", "V", "W", "X", "Y", "Z" };

    public static final String FORMAT_yyyyMMddHHmmssSSS = "yyyyMMddHHmmssSSS";

    public static String getOrderId() {
        // 设定服务端时间
        SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_yyyyMMddHHmmssSSS);
        String sNow = sdf.format(new Date());

        return sNow + EBeiUtil.generate8Uuid();
    }

    public static String generate8Uuid() {
        StringBuffer shortBuffer = new StringBuffer();
        String uuid = UUID.randomUUID().toString().replace("-", "");
        for (int i = 0; i < 8; i++) {
            String str = uuid.substring(i * 4, i * 4 + 4);
            int x = Integer.parseInt(str, 16);
            shortBuffer.append(chars[x % 0x3E]);
        }
        return shortBuffer.toString();
    }

    /**
     * 金币的金币有限期类型（ 固定时间段   01,按季度计算有效期  02,有效天数  03）
     */
    public static final String GoldCorn_Fixed_Period = "01";

    public static final String GoldCorn_Quarterly_Validity = "02";

    public static final String GOLdCorn_Effective_Days = "03";

    /**
     * “审核中”： 01,“打回”：  02,“待发行”： 03,“发行/使用中”：0 4,“作废”： 05,“仅使用，停止发行”：06;,
     * 
     */
    public static final String GoldCorn_review = "01";

    public static final String GoldCorn_back = "02";

    public static final String GoldCorn_Pending_issue = "03";

    public static final String GoldCorn_Useing = "04";

    public static final String GoldCorn_cancel = "05";

    public static final String GoldCorn_Stop_issue = "06";

    /**
     *发放类型（固定发放个数   01，百分比 02，随机 03
     * 
     */
    public static final String GoldCorn_fixedDistributionNumber = "01";

    public static final String GoldCorn_percent = "02";

    public static final String GoldCorn_random = "03";

    // transactional_flow表中定义的金币type
    public static final String TRANSACTION_FLOW_EBEI_TYPE = "settlementForMarketingToEbei";

    // transactional_flow表中定义的金币status
    public static final String TRANSACTION_FLOW_EBEI_STATUS_UNSETTLEMENT = "00"; // 未结算

    public static final String TRANSACTION_FLOW_EBEI_STATUS_INSETTLEMENT = "01"; // 结算中

    public static final String TRANSACTION_FLOW_EBEI_STATUS_DIDSETTLEMENT = "02"; // 已结算

    //金币主动发放的标志

    public static final String EBEI_ZDFF_GOLDCORN = "ZDFF000001";

}
